﻿using System;
using System.Diagnostics;
using System.Linq.Expressions;

namespace WooCoo.DataPortal.Client
{
    /// <summary>
    /// 查询表达式基类
    /// </summary>
    public abstract class QueryOptionExpression : Expression
    {
        /// <summary>The CLR type this node will evaluate into.</summary>
        private Type type;
        /// <summary>
        /// Creates a QueryOptionExpression expression
        /// </summary>
        /// <param name="nodeType">expression node type</param>
        /// <param name="type">the return type of the expression</param>
        public override Type Type
		{
			get
			{
				return this.type;
			}
		}
        public QueryOptionExpression(Type type)            
        {
            this.type = type;
        }

        /// <summary>
        /// Composes the <paramref name="previous"/> expression with this one when it's specified multiple times.
        /// </summary>
        /// <param name="previous"><see cref="QueryOptionExpression"/> to compose.</param>
        /// <returns>
        /// The expression that results from composing the <paramref name="previous"/> expression with this one.
        /// </returns>
        public virtual QueryOptionExpression ComposeMultipleSpecification(QueryOptionExpression previous)
        {
            Debug.Assert(previous != null, "other != null");
            Debug.Assert(previous.GetType() == this.GetType(), "other.GetType == this.GetType() -- otherwise it's not the same specification");
            return this;
        }
    }
}
